﻿<%@ Page Language="C#" MasterPageFile="~/Site.master" Title="Using Specified Foreign-Keys" %>

<%@ Register src="~/DynamicData/Content/GridViewPager.ascx" tagname="GridViewPager" tagprefix="asp" %>

<asp:Content ID="headContent" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

  <asp:DynamicDataManager  ID="DynamicDataManager1" runat="server">
    <DataControls>
        <asp:DataControlReference ControlID="GridView1" />
    </DataControls>
  </asp:DynamicDataManager>
   
    <h2 class="DDSubHeader">Fitering Products Table Rows Using Specified Foreign-keys</h2>

    <div class="ExampleView">
        Dynamic Data creates the UI to filter table rows by using the default 
        filter templates that are in the ~\DynamicData\Filters folder. <br />
        The default templates support foreign-key, Boolean, and enumeration column types. <br />
        The example uses the 
	    <a href="http://msdn.microsoft.com/en-us/library/system.web.dynamicdata.dynamicfilterexpression(VS.100).aspx" target="_blank"> 
        <code>System.Web.DynamicData.DynamicFilterExpression</code></a> control to create the UI for filtering 
        rows by using the specified foreign-keys <i>ProductCategory </i> and <i>ProductModel</i>.
    </div>
   
    <hr />
      
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true"
                HeaderText="Vui lòng sửa lại các lỗi dưới đây" />
            <asp:DynamicValidator runat="server" ID="GridViewValidator" ControlToValidate="GridView1" Display="None" />
        
            <asp:QueryableFilterRepeater ID="FilterRepeater1" runat="server">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" 
                        Text='<%# Eval("DisplayName") %> '/>
                    <asp:DynamicFilter ID="DynamicFilter" runat="server" />
                </ItemTemplate>
            </asp:QueryableFilterRepeater>

            <br /> <br />
            
            <asp:GridView ID="GridView1" CssClass="DDGridView" runat="server"
                DataSourceID="GridDataSource" AutoGenerateColumns="false"
                AllowPaging="true" AllowSorting="true">
                <Columns>
                    <asp:DynamicField DataField="ProductCategory" />
                    <asp:DynamicField DataField="ProductModel" />
                    <asp:DynamicField DataField="Name" />
                    <asp:DynamicField DataField="Color" />
                    <asp:DynamicField DataField="Size" />
               </Columns>
            </asp:GridView>
            
            <asp:QueryExtender ID="QueryExtender1" runat="server" 
                TargetControlID="GridDataSource">
                <asp:DynamicFilterExpression ControlID="FilterRepeater1" />
            </asp:QueryExtender>
           
                
            <asp:EntityDataSource ID="GridDataSource" runat="server" EnableDelete="True" 
                ContextTypeName="AdventureWorksLT_DataModel.AdventureWorksLT_DataEntities" 
                EnableFlattening="False" 
                EntitySetName="Products"  />
        
        </ContentTemplate>
    </asp:UpdatePanel>
        
 </asp:Content>
